class Solution {
public:
    TreeNode* pruneTree(TreeNode* root) {
        if(!root){
            return NULL;
        }
        TreeNode* l = pruneTree(root->left);
        TreeNode* r = pruneTree(root->right);
        
        root->left = l;
        root->right = r;
        
        if(!l && !r && root->val == 0){
            return NULL;
        }
        
        return root;
    }
};
